package com.wenzhi.studentservice.aopuse;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class AopPractice {
    public static void main(String[] args) {
        // Cal cal = new CalImpl();
        // System.out.println(cal.add(1, 2));
        // System.out.println(cal.sub(1, 2));
        try (AnnotationConfigApplicationContext context =
                     new AnnotationConfigApplicationContext("com.wenzhi.studentservice.aopuse")) {
            // CalImpl bean = context.getBean(CalImpl.class); // CalImpl无@EnableAspectJAutoProxy // 9 3
             Cal bean = (Cal) context.getBean("calImpl"); // CalImpl有@EnableAspectJAutoProxy // 默认类名首字母小写

            System.out.println(bean.add(6, 3));
            System.out.println(bean.sub(6, 3));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
